package sm.def;

public enum KeyType {
	UNIQUE(12, "Unique"), NO_NULLS(4, "No Nulls"), NO_DUPLICATES(8,
			"No Duplicates"), NULL_AND_DUPLICATES(0, "Null & Duplicates"), IR_KEY(
			64, "IR Key");

	private int flags;

	private String name;

	public int getFlags() {
		return flags;
	}

	public String getName() {
		return name;
	}

	private KeyType(int flags, String name) {
		this.flags = flags;
		this.name = name;
	}

	public static KeyType getType(int number) {
		switch (number) {
		case 12:
			return UNIQUE;
		case 4:
			return NO_NULLS;
		case 8:
			return NO_DUPLICATES;
		case 0:
			return NULL_AND_DUPLICATES;
		case 64:
			return IR_KEY;
		default:
			return null;
		}
	}

	public static boolean isUniqueKey(int number) {
		switch (number) {
		case 12:
		case 8:
			return true;
		default:
			return false;
		}
	}

	public static boolean isNotNullKey(int number) {
		if (number == 4) {
			return true;
		} else {
			return false;
		}
	}

}
